<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>JsonP的知识</title>
  </head>
  <body>
    <script>
      // Jsonp实际上就是通过<script>标签能够跨域进行处理
      // 一般后端浏览器返回类似于
      HandleResponse({
        code: 200,
        data: [
          {
            word: "jsp",
          },
          {
            word: "js",
          },
        ],
      });

      // 需要自己在前端声明函数
      const HandleResponse = (data) => {
        console.log(data);
      };

      // 一般是动态加载
      const script = document.createElement("script");
      script.src = "http:127.0.0.1/jsonp?callback=handleResponse";
      document.body.appendChild(script);
    </script>
  </body>
</html>
